Rendering multiple render passes or textures

Use a Blit Render Pass to blit multiple Composition Target Render Pass resources or textures to the screen. By default a Blit Render Pass uses only one Composition Target Render Pass or texture.

To blit multiple Composition Target Render Pass resources or textures to the screen:

  1. Create a material type which supports blitting multiple textures. See Modifying the DefaultBlit material type to support multiple textures.
  2. Use a Blit Render Pass to blit multiple Composition Target Render Pass resources or textures to the screen. See Blitting multiple textures to the screen.

Modifying the DefaultBlit material type to support multiple textures

To make the DefaultBlit material type support multiple textures:

  1. In the Library > Materials and Textures > Material Types > DefaultBlit double-click the Fragment Shader to open it in the Shader Source Editor.
    TIP

    If your project does not contain the DefaultBlit material type, in the Library > Materials and Textures > Material Types press Alt and right-click, and select DefaultBlit.

  2. In the Shader Source Editor add the uniforms you want the Blit Render Pass to use and modify the shader to use them.
    For example, to make the shader mix the Texture0 and Texture1 properties using the custom property Weight to weigh between them, replace the contents of the shader file with
    uniform sampler2D Texture0;
    uniform sampler2D Texture1;
    uniform mediump float Weight;
    
    varying mediump vec2 vTexCoord;
    
    void main()
    {
        precision lowp float;
    
        gl_FragColor = mix(texture2D(Texture0, vTexCoord), texture2D(Texture1, vTexCoord), Weight);
    }
    Click Save.
  3. In the Library > Materials and Textures > Material Types select the DefaultBlit material type and in the Properties click Sync with Uniforms to add the missing properties for the materials that use this material type.
  4. In the Create Property Type window click Yes to create the custom property type Weight you use to weigh between the Texture0 and Texture1 properties, in the Property Type Editor set the Default Value property to 0,5, and click Save.
  5. To make the DefaultBlitMaterial transparent, in the Library > Materials and Textures > Materials select DefaultBlitMaterial, and in the Properties set the Blend Mode property.
    For example, set the Blend Mode property to Alpha: Automatic.
  6. (Optional) Because you set the Default Value of the Weight property type to 0,5, by default the materials that use the DefaultBlit material type show the average of the Texture0 and Texture1 properties.
    To adjust this select the material that uses the DefaultBlit material type and set the value of the Weight property. To give more weight to Texture0, decrease the value of the Weight property, and to give more weight to Texture1, increase the value.
  7. Use DefaultBlitMaterial in a Blit Render Pass to blit multiple Composition Target Render Pass resources or textures to the screen. See Blitting multiple textures to the screen.

Blitting multiple textures to the screen

To blit multiple Composition Target Render Pass resources or textures to the screen:

  1. In the Library > Rendering > Render Passes create a Group Render Pass and inside it create:
  2. In the Library > Rendering > Render Passes > Group Render Pass select the Blit Render Pass and set:
  3. In the Project select the Scene node the content of which you want to render with the Composition Target Render Pass and in the Properties set the Render Pass property to the Group Render Pass you created in the first step.
    Kanzi now renders the Scene using the render passes you created.

  4. In the Library > Rendering > Render Passes > Group Render Pass select the Blit Render Pass and in the Properties add and set the Texture properties to the texture or Composition Target Render Pass resources you want to use.
    For example, add the Texture1 property and set it to a texture resource.

  5. (Optional) In the Library > Rendering > Render Passes > Group Render Pass select the Composition Target Render Pass and in the Properties set:

See also

Rendering

Using material types

Shaders

Textures